using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DatabaseHelper
{
    public abstract class DbFunction
    {
        protected const string _connectionString = "Data Source={0};Initial Catalog={1};User ID={2};Password={3}";

        protected virtual string GetDataTableValueString(DataTable dt, int rowIndex, string columnName)
        {
            string result=string.Empty;
            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                   result= Convert.ToString(dt.Rows[rowIndex][columnName]);
                }
            }
            return result;
        }

        protected virtual int GetDataTableValueInt(DataTable dt, int rowIndex, string columnName)
        {
            int result = 0;
            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    result = Convert.ToInt32(dt.Rows[rowIndex][columnName]);
                }
            }
            return result;
        }

        protected virtual string GetDataRowValueString(DataRow row, string columnName)
        {
            string result = string.Empty;
            if (row != null)
            {
                result = Convert.ToString(row[columnName]);
            }
            return result;
        }

        protected virtual string GetDataValueString(DataRow row, int rowIndex)
        {
            string result = string.Empty;
            if (row != null)
            {
                result = Convert.ToString(row[rowIndex]);
            }
            return result;
        }
       
    }
}
